package com.test.hello.model;

import java.beans.Transient;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class User {
    private Long id;

    private String username;

    private String password;
    
    private List<Role> roleList;//一个用户具有多个角色  
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username == null ? null : username.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }
    public List<Role> getRoleList() {  
        return roleList;  
    }  
    public void setRoleList(List<Role> roleList) {  
        this.roleList = roleList;  
    }
    @Transient
    public Set<String> getRolesName(){  
        List<Role> roles=getRoleList();  
        Set<String> set=new HashSet<String>();  
        for (Role role : roles) {  
            set.add(role.getRolename());  
        }  
        return set;  
    }  
}